● Zion Boggan
repos/Docket/app/api/votes/[id]/route.ts
zionboggan.com ↗
17 lines · typescript
History for this file →
1
import { NextResponse, type NextRequest } from "next/server";
2
import { getVoteById } from "@/lib/feed";
3
 
4
export const dynamic = "force-dynamic";
5
 
6
 
7
export async function GET(
8
  _req: NextRequest,
9
  { params }: { params: { id: string } }
10
) {
11
  const numeric = parseInt(params.id.replace(/^vote:/, ""), 10);
12
  const vote = Number.isFinite(numeric) ? getVoteById(numeric) : null;
13
  if (!vote) {
14
    return NextResponse.json({ error: "not found" }, { status: 404 });
15
  }
16
  return NextResponse.json(vote);
17
}